from lina.mongodb import db
from bson import ObjectId

from lina.service.BaseService import BaseService

TABLE_NAME = 'task'


class TaskService(BaseService):

    def __init__(self):
        self.table_name = TABLE_NAME
        super().__init__()

    def fetch_tasks_by_case_id(self, case_id):
        # 查询一个案件的所有评论
        table = db()[TABLE_NAME]
        caseId = ObjectId(case_id)

        obj_list = []
        for obj in table.find({"case_id": caseId}):
            obj_list.append(obj)

        return obj_list
